package com.sansui.blog.controller;

import com.sansui.blog.pojo.SysConfig;
import com.sansui.blog.service.SysInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.*;

/**
 * @name: GeneralToolController
 * @author: Sansui
 * @Software: IDEA
 * @Blog: https://www.cnblogs.com/sansui6/
 * @date: 2022-07-23 17:48
 * 通用工具类  用于获取个别所需字段数据
 **/
@RestController
public class GeneralToolController {


    @Autowired
    private SysInfoService sysInfoService;


    //获取系统创建时间
    @GetMapping("/getCreateTime")
    public Map<String, Object> getCreateTime(){
        Map<String,Object> data = new HashMap<>(16);
        try{
            SysConfig sysConfig = sysInfoService.getSysSetting();
            Map<String,Object> createTime = new HashMap<>(16);
            createTime.put("createTime",sysConfig.getCreateTime());
            data.put("code",200);
            data.put("data",createTime);
        }catch (Exception e){
            data.put("code",400);
        }
        return data;
    }

    //获取系统统计代码
    @GetMapping("/getTongji")
    public Map<String, Object> getTongji(){
        Map<String,Object> data = new HashMap<>(16);
        try{
            SysConfig sysConfig = sysInfoService.getSysSetting();
            Map<String,Object> tongji = new HashMap<>(16);
            tongji.put("tongji",sysConfig.getTongji());
            data.put("code",200);
            data.put("data",tongji);
        }catch (Exception e){
            data.put("code",400);
        }
        return data;
    }

////    获取网站名称
//    @PostMapping("/getWebName")
//    public Map<String, Object> getWebName(){
//        Map<String,Object> data = new HashMap<>(16);
//        try{
//            SysConfig sysConfig = sysInfoService.getSysSetting();
//            Map<String,Object> sysData = new HashMap<>(16);
//            sysData.put("webName",sysConfig.getWebname());
//            data.put("code",200);
//            data.put("data",sysData);
//        }catch (Exception e){
//            data.put("code",400);
//        }
//        return data;
//    }



}
